package lang;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2021/11/05
 */
public class RandomNumTest {

    private static final Logger logger = LoggerFactory.getLogger(RandomNumTest.class);

    int number = 20;

    /**
     * 生成[0,9]之间的随机整数。
     */
    @Test
    public void test2() {
        for (int i = 0; i < number; i++) {
            int b = (int) (Math.random() * 10);
            logger.info(String.valueOf(b));
        }
    }

    /**
     * 生成从m到n的随机整数[m,n]
     */
    @Test
    public void test3() {
        int m = 1;
        int n = 5;
        for (int i = 0; i < number; i++) {
            int temp = m + (int) (Math.random() * (n + 1 - m));
            logger.info(String.valueOf(temp));
        }
    }

}
